﻿<!DOCTYPE html>
<!--隐患排查上报管理编辑-->
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
        <script src="/static/js/common.js"></script>

    <style>
        .el-dialog__body {
            height: 100% !important;
        }

        .el-dialog.is-fullscreen {
            overflow: hidden !important;
        }

        body {
            padding-bottom: 10px;
        }

        /*说明：
         由于mystyle.css中162行.el-form-item__content {line-height: normal!important;}导致的
         index.css中.el-form-item--mini .el-form-item__content, .el-form-item--mini .el-form-item__label{    line-height: 28px;}失效
         但出于无法修改样式表的情况，所以在该页面添加以下样式，以保证页面内标题和内容不偏离
        */
        .el-form-item--mini .el-form-item__content,
        .el-form-item--mini .el-form-item__label {
            line-height: 28px !important;
        }
    </style>
    <style>
        ._delete-icon {
            position: absolute;
            right: 5px;
            bottom: 13px;
            cursor: pointer;
            display: none;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak class="popupW100">
        <el-form :model="Form" status-icon :rules="rules" ref="ruleForm" label-width="100px" size="mini"
            label-position="right">
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="RisksManagement.RiskReport.Discoverer+mark.m" class="inputTextarea">
                                {{Form.Discoverer}}
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.OrganizationType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.OrganizationType" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.OrganizationType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in OrganizationType" :label="item.value"
                                            :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        {{RisksManagement.RiskReport.DiscoveryTime+mark.m}}
                                    </template>
                                    <el-date-picker slot="suffix" v-model="Form.DiscoveryTime"
                                        format="yyyy-MM-dd HH:mm:ss" value-format="yyyy-MM-dd HH:mm:ss" type="date"
                                        size="mini" placeholder="选择时间">
                                    </el-date-picker>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.InspectType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.InspectType" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.InspectType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in InspectType" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskRegion+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.RiskRegion" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.RiskRegion" @change="getNext($event)">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskRegion" :label="item.label" :value="item.id">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskPosition+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.RiskPosition" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.RiskPosition">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskPosition" :label="item.label" :value="item.id">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskType+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.RiskType" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.RiskType">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskType" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="11" offset="2">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item>
                                <el-input size="mini">
                                    <template slot="prepend">
                                        <div> {{RisksManagement.RiskReport.RiskLevel+mark.m}}</div>
                                    </template>
                                    <el-select @visible-change="visibleChange" v-model="Form.RiskLevel" slot="suffix"
                                        :placeholder="RisksManagement.RiskReport.RiskLevel">
                                        <el-option label="请选择" value=""></el-option>
                                        <el-option v-for="item in RiskLevel" :label="item.value" :value="item.key">
                                        </el-option>
                                    </el-select>
                                </el-input>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>

            </el-row>
            <el-row>
                <el-col :span="11">
                    <el-col>
                        <div class="elst-select-mini">
                            <el-form-item :label="RisksManagement.MajorRiskDossier.MajorRiskDossier+mark.m"
                                class="inputTextarea">
                                <el-link :underline="false" @click="OpenMajorRiskDossier" type="primary"
                                    style="font-size: 14px;color:#409eff;cursor:pointer;">
                                    {{RisksManagement.MajorRiskDossier.MajorRiskDossier}}名称</el-link>
                            </el-form-item>
                        </div>
                    </el-col>
                </el-col>
                <el-col :span="8" offset="2">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <el-input v-model="Form.ScreeningStandard" autocomplete="off" size="mini" disabled="true">
                                <template slot="prepend">
                                    {{RisksManagement.RiskReport.ScreeningStandard+mark.m}}
                                </template>
                            </el-input>
                        </el-form-item>
                    </div>
                </el-col>
                <el-col :span="3">
                    <el-button type="primary" class="fr" @click="addStandard">排查标准选择</el-button>
                </el-col>

            </el-row>
            <el-row>

                <el-col :span="24">
                    <div class="elst-select-mini">
                        <el-form-item>
                            <div class="el-input--mini el-input-group">
                                <div class="el-input-group__prepend">
                                    {{RisksManagement.RiskReport.RiskDescription+mark.m}}
                                </div>
                                <el-input class="el-textarea__inner" type="textarea" v-model="Form.RiskOfViolation"
                                    autocomplete="off"></el-input>
                            </div>
                        </el-form-item>
                    </div>
                </el-col>
            </el-row>
            <el-row>
                <el-col :span="24">

                    <el-form-item :label="RisksManagement.RiskReport.BeforeRectificationImg+mark.m"
                        prop="BeforeRectificationImg" class="inputTextarea" style="position:relative;">

                        <el-upload class="upload-demo" :show-file-list="false" accept=".jpg,.jpeg,.png,.gif" action=""
                            :limit="1" :on-change="UploadChange" style="position:absolute;top:26px;left:-95px;">
                            <el-button type="primary">{{col.btnUpLoad}}</el-button>
                        </el-upload>

                        <div v-for="src in Form.BeforeRectificationImg"
                            style="float:left;margin-right:5px;position:relative;" class="ImgBox">
                            <i class="el-icon-delete _delete-icon" @click="deleteImg(src.id)"></i>
                            <el-image :src="src.Img" fit="fill" width="200" height="100">
                            </el-image>
                        </div>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row type="flex" justify="end">
                <el-form-item>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnSave}}</el-button>
                    <el-button type="primary" @click="onSubmitForm('ruleForm')">{{col.btnCommit}}</el-button>
                    <el-button type="primary" @click="parent.ListItem.dialogVisible=false">{{col.btnBack}}</el-button>
                </el-form-item>
            </el-row>
        </el-form>
        <el-dialog :title="title" :visible.sync="ListItem.dialogVisible" width="80%" height="80%" top="10vh"
            fullscreen="true">
            <iframe ref="iframe" :src="ListItem.InputUrl" style="height:95%;width:100%" frameborder="0"></iframe>
        </el-dialog>
    </div>
    <script>
        //图片删除图标
        $(function () {
            $('body').on('mouseenter mouseleave', '.el-image', function (e) {
                if (e.type == 'mouseenter') {
                    $(this).prev("i").show();
                }
                else if (e.type == 'mouseleave') {
                    $(this).prev("i").hover(function () {
                        $(this).show()
                    }).hide()
                }
            })
        })
    </script>
    <script type="text/javascript">

        app = new Vue({
            el: '#app',
            data: {
                //父业传参
                id: '',
                mydata: myTree,
                ListItem: ListItem,
                title: '',
                //业务表单内容
                Form: {
                    id: guidEmpty,
                    Discoverer: '',
                    DiscoveryTime: '',
                    OrganizationType: '',
                    InspectType: '',
                    RiskRegion: '',
                    RiskPosition: '',
                    RiskType: '',
                    RiskLevel: '',
                    RiskDescription: '',
                    ScreeningStandard: '',
                    BeforeRectificationImg: [],
                },
                OrganizationType: [],
                InspectType: [],
                RiskRegion: [],
                RiskPosition: [],
                RiskType: [],
                RiskLevel: [],
                //表单验证
                rules: {

                }
            },
            methods: {
                //解決edge下select bug
                visibleChange: function (isVisible) {
                    visibleChange(isVisible)
                },
                //重大隐患项目档案
                OpenMajorRiskDossier: function () {
                    var id = '123';
                    this.title = '重大隐患档案名称';
                    this.ListItem.InputUrl = "../MajorRisk/MajorRiskDossierInput.html?type=ck&id=" + id + "&t=" + Date.parse(new Date());
                    this.ListItem.dialogVisible = true;
                },
                addStandard: function (val, id) {
                    this.title = '排查标准选择';
                    DialogShow(this, val, "RiskReportInputAddStandard.html", id);
                },
                //上传状态改变事件，随便选个可触发的钩子模拟上传
                UploadChange: function (file, filelist) {
                    if (file.status == 'ready') {

                        this.Form.BeforeRectificationImg.push({
                            id: Mock.Random.id(),
                            Img: Mock.Random.image('200x100', '#1989fa', '#FFFFFF', 'Test Image' + ($(".ImgBox").length + 1)),
                        });
                    }
                    else if (file.status == 'fail') {

                    }
                },
                //提交数据
                onSubmitForm: function (formName) {
                    var mythis = this;
                    this.$refs[formName].validate(function (valid) {
                        //验证通过
                        if (valid) {
                            onSubmitForm(this, '/api/RiskReport/Save', mythis.Form);
                        } else {
                            //验证失败
                            return false;
                        }
                    });

                },
                getData: function () {

                    getData(this, '/api/RiskReport/get?id=' + this.id);
                    this.RiskPosition = [];
                    this.RiskPosition = fn(this.mydata, this.Form.RiskRegion);
                },
                //二级联动
                getNext: function (prov) {
                    this.RiskPosition = [];
                    this.Form.RiskPosition = '';
                    this.RiskPosition = fn(this.mydata, prov);

                },
                //图片临时删除
                deleteImg: function (id) {
                    var list = this.Form.BeforeRectificationImg;
                    this.$confirm(' 是否确认继续?', '提示', {
                        confirmButtonText: '确定',
                        cancelButtonText: '取消',
                        type: 'warning'
                    }).then(function () {
                        list.forEach(function (v, i) {
                            if (v.id + '' === id + '') {
                                list.splice(i, 1);
                            }
                        })
                    }).catch(function () {
                        showMessage("已取消删除!");
                    });
                }
            },
            mounted: function () {
                this.RiskLevel = getDicData('03');
                this.RiskType = getDicData('100');
                this.RiskRegion = fn(this.mydata, "0");
                this.OrganizationType = getDicData('103');
                this.InspectType = getDicData('101');
                this.id = getUrlParam("id");
                this.getData();
                if (!this.id) {
                    this.Form.Discoverer = Mock.Random.cname();
                }


                //var xx = {};

                //xx.time = this.Form.DiscoveryTime;

                //this.Form.DiscoveryTime1 = xx.time;
                //this.Form.DiscoveryTime2 = xx.time;
                ////this.Form.DiscoveryTime = '2019-09-09';


                //this.$set(this.Form, "DiscoveryTime", xx.time)


                //console.log('Form.DiscoveryTime', this.Form.DiscoveryTime);

            }
        });
    </script>
</body>

</html>